<?php

use Illuminate\Support\Facades\Cache;

/**
 * Carbon helper
 *
 * @param $time
 * @param $tz
 *
 * @return Carbon\Carbon
 */
// function get_token($status = false)
// {
//     if ($status) {
//         $resultArr = get_url_token();
//         Cache::put('changgeng_token', $resultArr, $resultArr['expires_in']);
//     } else {
//         $resultArr = Cache::get('changgeng_token');
//         if (!$resultArr) {
//             $resultArr = get_url_token();
//             Cache::put('changgeng_token', $resultArr, $resultArr['expires_in']);
//         }
//     }
//     return $resultArr;
// }

function get_url_token()
{
    $client = new \GuzzleHttp\Client();
    $response   = $client->get('http://ee.bzh001.com/wechat-token');
    $resultJson = $response->getBody()->getContents();
    return json_decode($resultJson, 1)['access_token'];
}
